package com.example.questionnaires.common;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;

import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class PageResult<T extends Object> {
    private List<T> records;
    private long total;
    private long size;
    private long current;

    public PageResult(Page<T> page) {
        this.records = page.getRecords();
        this.total = page.getTotal();
        this.size = page.getSize();
        this.current = page.getCurrent();
    }

    public static <T> PageResult<T> build(List<T> records, long total, long size, long current) {
        return new PageResult<>(records, total, size, current);
    }
} 